#ifndef CX_TIMER_H
#define CX_TIMER_H
#include "cx_list.h"
#include "cx_typedef.h"
#ifdef USE_DYNAMIC_MALLOC
#include "cx_heap.h"
#endif

typedef enum{
    TriggerTypeNormal = 0,
    TriggerTypeOneShot = 1
}cx_trigger_type_enum_t;

typedef struct cx_software_timer
{
    struct cx_slist_item *next;

    cx_u32 gap;
    cx_u32 trigger_tick;
    cx_trigger_type_enum_t trigger_type;
    void (*cb_handler)(void *);
    void *args;
}cx_software_timer_t;

typedef struct cx_sw_timer_interface
{

#ifndef CX_LIB_DISABLE_TIMER_TIMESTAMP
    cx_uint StampsPerTick;
#endif
    cx_uint64_t ticks;
    cx_slist_t sw_timer_list;
    cx_software_timer_t *cur_sw_timer;
}cx_sw_timer_interface_t;
int cx_sw_timer_init(cx_sw_timer_interface_t *timer_itf);
void SoftHandler(cx_sw_timer_interface_t *timer_itf);
int cx_sw_timer_regSoftwareTimer(cx_sw_timer_interface_t *timer_itf, cx_software_timer_t *sw_timer);
int cx_sw_timer_logoutSoftwareTimer(cx_sw_timer_interface_t *timer_itf, cx_software_timer_t *sw_timer);

#endif
